import { useRequest } from "ahooks";
import { useModel } from '@umijs/max';

export default function useProjectList() {
    const {
        initialState,
        setInitialState,
    } = useModel('@@initialState');

    const { 
        proList,
        fetchProject,
     } = initialState;

     const getPro = useRequest(
        () => {
          return fetchProject();
        },
        {
          manual: true,
          onSuccess: (res) => {
            setInitialState((s) => ({
              ...s,
              proList: res,
            }));
          },
        },
      );

    return { initialState,setInitialState, proList, getPro };
}